using System;
using System.Web.Services.Protocols;

using SBPweb.Data.Generic;

#if SOAP
namespace SBPweb.Data.SOAP
{

	/// <summary>
	/// This class implements basic functionallity of web service based repositories
	/// </summary>
	/// <typeparam name="TDomainObject">Domain object</typeparam>
	public abstract class WebServiceRepository<TDomainObject> : IRepository<IEntity>
	{

		#region Private members

		/// <summary>
		/// SoapHttpClientProtocol mService
		/// </summary>
		protected SoapHttpClientProtocol mService;
		private Uri mUrl;

		#endregion

		#region Public properties

		/// <summary>
		/// Gets or sets the Url of the web service
		/// </summary>
		public Uri Url
		{
			get
			{
				return mUrl;
			}
			set
			{
				mUrl = value;
				if(mService != null)
				{
					mService.Url = value.ToString();
				}
			}
		}

		#endregion

		#region IRepository<IEntity> Members

		/// <summary>
		/// Commits transaction
		/// </summary>
		/// <param name="item">TDomainObject item</param>
		public abstract void Commit(IEntity item);
		/// <summary>
		/// Rollbacks transaction
		/// </summary>
		/// <param name="item">TDomainObject item</param>
		public abstract void Rollback(IEntity item);
		/// <summary>
		/// Starts transaction
		/// </summary>
		public abstract void BeginTransaction();

		#endregion

	}
}
#endif